package com.cheer.param;

import cn.hutool.json.JSONUtil;
import com.cheer.entity.ActivityEntity;
import com.cheer.vo.ImgVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(description = "活动（新增/修改）")
public class ActivityAddOrUpParam {

    private Integer id;

    @ApiModelProperty("活动形式 1 活动打卡 2 活动展示")
    @NotNull(message = "活动形式不能为空")
    private Integer type;

    @ApiModelProperty("机构限制")
    @NotNull(message = "机构限制不能为空")
    private Boolean orgLimit;

    @ApiModelProperty("机构ID")
    private Integer pid;

    @ApiModelProperty("活动标题")
    @NotBlank(message = "活动标题不能为空")
    @Length(min = 0, max = 20 , message = "活动标题长度必须在1~20之间")
    private String title;

    @ApiModelProperty("活动内容")
    @NotBlank(message = "活动内容不能为空")
    @Length(min = 0, max = 500 , message = "活动内容长度必须在1~500之间")
    private String content;

    @ApiModelProperty("活动时间 开始日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty("活动时间 结束日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty("打卡时间 开始日期")
    private String checkinStartTime;

    @ApiModelProperty("打卡时间 结束日期")
    private String checkinEndTime;

    @ApiModelProperty("活动地址 （地图）")
    @NotBlank(message = "活动地址不能为空")
    @Length(min = 0, max = 100 , message = "活动地址长度必须在1~100之间")
    private String address;

    @ApiModelProperty("坐标经度")
    private String locationLatitude;

    @ApiModelProperty("坐标纬度")
    private String locationLongitude;

    @ApiModelProperty("有效范围")
    private Integer locationRange;

    @ApiModelProperty("注意事项")
    private String notes;

    @ApiModelProperty("展示文字")
    private String achieveText;

    @ApiModelProperty("详情图片")
    @NotEmpty(message = "活动详情图不能为空")
    private List<ImgVO> images;

    @ApiModelProperty("缩略图")
    @NotEmpty(message = "活动图不缩略图不能为空")
    private List<ImgVO> thumbnail;

    @ApiModelProperty("展示图片")
    private List<ImgVO> achieveImage;

    /**
     * 获取image 存储为str格式
     * @return
     */
    public String getAchieveImageStr(){
        List<String> list = new ArrayList<>();
        for (int i = 0; i < achieveImage.size(); i++) {
            ImgVO imgVO = achieveImage.get(i);
            list.add(imgVO.getName());
        }
        return JSONUtil.toJsonStr(list);
    }

}
